package com.api.main.mvc.dao;

import com.api.main.mvc.dao.mapper.OrgUserMapper;
import com.api.main.mvc.dao.pojo.OrgUserDO;
import com.api.main.mvc.dao.pojo.table.OrgUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class OrgUserRepository {

    @Resource
    private OrgUserMapper orgUserMapper;

    public OrgUserDO getUser(String userName) {
        QueryWrapper<OrgUserDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(OrgUser.TABLE_FIELD_USER_NAME, userName);
        return orgUserMapper.selectOne(queryWrapper);
    }

    public void update() {
        OrgUserDO orgUserDO = new OrgUserDO();
        orgUserDO.setUserName("admin");
        QueryWrapper<OrgUserDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(OrgUser.TABLE_FIELD_USER_NAME, "admin");
        orgUserMapper.update(orgUserDO, queryWrapper);
    }
}